/*
 * Copyright 2017-8-30 13:56:25 The JA-SIG Collaborative. All rights reserved.
 * distributed with thi file and available online at
 */
package com.lap.scp.admin.core.impl;

import java.util.Collections;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lap.scd.commons.core.exception.ManagerException;
import com.lap.scd.commons.page.Page;
import com.lap.scp.admin.core.TemplateManager;
import com.lap.scp.admin.dal.TemplateDAO;
import com.lap.scp.admin.domain.TemplateDO;
import com.lap.scp.admin.query.TemplateQueryDO;

/**
 * <pre>
 * // TODO 注释
 * </pre>
 * 
 * @author 系统自动生成 Exp
 * @Date 2017-8-30 13:56:25
 * @since 1.0
 */
@Service("templateManager")
public class DefaultTemplateManager implements TemplateManager {

	@Resource
	private TemplateDAO templateDAO;

	@Override
	public int deleteById(int templateId) throws ManagerException {
		return templateDAO.deleteById(templateId);
	}

	@Override
	public void insertTemplate(TemplateDO templateDO) throws ManagerException {
		templateDAO.insertTemplate(templateDO);
	}

	@Override
	public TemplateDO queryById(int templateId) throws ManagerException {
		return templateDAO.queryById(templateId);
	}

	@Override
	public List<TemplateDO> queryPage(Page page, TemplateQueryDO queryDO) throws ManagerException {
		int count = templateDAO.countPage(queryDO);
		if (count <= 0) {
			return Collections.emptyList();
		} else {
			page.setTotalItem(count);
			return templateDAO.queryPage(page, queryDO);
		}
	}

	@Override
	public int updateTemplate(TemplateDO templateDO) throws ManagerException {
		return templateDAO.updateTemplate(templateDO);
	}

}
